package com.example.springboot.mapper;

import com.example.springboot.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface UserMapper {

    @Select("select * from user")
    List<User> findAll();
    @Insert("INSERT into user(username,password,phone,unit,name,sfgl) VALUES (#{username},#{password},#{phone},#{unit},#{name},#{sfgl})")
    int insert(User user);

//    @Update("update user set username=#{username},password=#{password},phone=#{phone},unit=#{unit},name=#{name} where id = #{id}")
    int update(User user);

    @Delete("delete from user where id=${id}")
    Integer deleteById(@Param("id") Integer id);
@Select("select * from user where username like concat('%' ,#{username},'%')  limit #{pageNum},#{pageSize}")
    List<User> selectPage(Integer pageNum, Integer pageSize,String username);
@Select("select count(*) from user where username like concat('%' ,#{username},'%')")
    Integer selectTotal(String username);
}
